package main

import (
	"fmt"
	"strings"
)

func findMaxString(arr []string) string {
	length := len(arr) //数组长度
	if length <= 1 {
		return arr[0]
	} else {
		max := arr[0]

		for i := 0; i < length; i++ {
			if strings.Compare(arr[i], max) > 0 {
				max = arr[i]
			}

			fmt.Println(max)
		}
		fmt.Println("")
		return max
	}
}

func selectSortString(arr []string) []string {
	length := len(arr) //数组长度
	if length <= 1 {
		return arr
	} else {
		max := 0

		for i := 0; i < length-1; i++ {
			max = i

			for j := i + 1; j < length; j++ {
				if strings.Compare(arr[j], arr[max]) < 0 {
					max = j
				}
			}

			if max != i {

				arr[i], arr[max] = arr[max], arr[i]

			}

			fmt.Println(arr)
		}

	}
	return arr
}

func main() {
	arr := []string{"a1", "b1", "b2", "a10", "a5", "c1", "d3"}
	// fmt.Println(findMaxString(arr))

	fmt.Println(selectSortString(arr))

}
